/**
 * author:Administrator
 * date:2015/7/27
 * desc:TODO
 */

"use strict";

var mongoose = require('../mongodb.js');
var Schema = mongoose.Schema;

let RtToiSchema = new Schema({
    uid: {type: String, index: true, unique: true},
    tags: [{tag: String, value: Number}],
    createdAt: {type: Date, 'default': Date.now()},
    updatedAt: Date
});

RtToiSchema.pre('save', function (next) {
    if (!this.updatedAt) {
        this.updatedAt = new Date();
    }
    next();
});

// 指定collection name，默认是复数
var rtToi = mongoose.model('rtToi', RtToiSchema, 'rtToi');
exports = module.exports = rtToi;